const express = require('express');
const myroute = express.Router()
const mySql = require('../utils/database')
// 接受前端数据
myroute.get('/qbackcode', function (request, response) {
    let mybackcode = request.query.backcode
    // console.log(mybackcode);
    const sql = `SELECT * FROM  z_sale JOIN  production ON z_sale.p_id=production.p_id JOIN  out_stock ON out_stock.out_stock_id=production.p_ck_id JOIN  in_stock ON in_stock.in_stock_id=out_stock.rk_id JOIN  transport ON in_stock.trans_id=transport.t_id JOIN  tran_person ON tran_person.p_id=transport.t_person JOIN  purchase ON purchase.id=transport.t_shopid JOIN  goods ON purchase.p_item=goods.g_id JOIN  place ON place.p_id=goods.g_place JOIN  breeding ON breeding.b_id=goods.g_way  WHERE 销售单号='${mybackcode}'`
    mySql.query(sql, function (err, data) {
        // console.log(err, data);
        if (err) {
            console.log(err);
            response.send({ error: 1, msg: err })
        } else {
            response.send({ error: 0, data: data })
        }
    })

})
module.exports = myroute